<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../css/app.css" />
		<style>
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">公告设置</h1>
		</header>
		<div class="mui-content">
			<div class="mui-card">
				<div class="mui-card-content">
					<textarea id="content" style="width: 100%;min-height: 18.75rem;"></textarea>
					<button id="sub" type="button" class="mui-btn mui-btn-danger" style="width: 100%;">保存</button>
				</div>
			</div>
		</div>

	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/config.js"></script>
	<script>
		var words;
		mui.init({

		});
		mui.plusReady(function() {
			init();
		});

		function init() {
			mui.ajax(config.config.path + "/config/notice", {
				type: "GET",
				dataType: "json",
				success: function(result) {
					var code = result.code;
					if (code == 200) {
						var html = "";
						words = result.data;
						document.getElementById("content").innerText = words.value;
					}
				}
			});
		}

		document.getElementById("sub").addEventListener('tap', function() {
			words.value = document.getElementById("content").value;
			mui.confirm('确认保存吗？', '提示', ['确认', '取消'], function(e) {
				if (e.index == 0) {
					mui.ajax(config.config.path + "/config/edit?token=eara123*", {
						data: words,
						contentType: 'application/json;charset=utf-8',
						type: "PUT",
						dataType: "json",
						success: function(result) {
							var code = result.code;
							if (code == 200) {
								mui.toast('保存成功', {
									duration: 'short',
									type: 'div'
								});
							} else {
								mui.toast(result.message, {
									duration: 'short',
									type: 'div'
								});
							}
						}
					});
				}
			}, 'div');
		})
	</script>
</html>
